package com.xinyu.controller;


import com.xinyu.domain.Words;
import com.xinyu.service.IWordsService;
import com.xinyu.vo.BaseResult;
import com.xinyu.vo.WordsRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author l
 * @since 2025-02-20
 */
@RestController
@RequestMapping("/words")
public class WordsController {

    @Autowired
    private IWordsService wordsService;

    @PostMapping("queryByCondition")
    public ResponseEntity<BaseResult> queryByCondition(@RequestBody WordsRequest wordsRequest){
        BaseResult br = wordsService.queryByCondition(wordsRequest);
        return ResponseEntity.ok(br);
    }


    @PostMapping("/save")
    public ResponseEntity<BaseResult> save(@RequestBody Words words) {
        wordsService.save(words);
        return ResponseEntity.ok(BaseResult.ok());
    }


    @PostMapping("/update")
    public ResponseEntity<BaseResult> update(@RequestBody Words words) {
        wordsService.updateById(words);
        return ResponseEntity.ok(BaseResult.ok());
    }

}

